/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package entity;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Embeddable;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;

/**
 *
 * @author antonio
 */
@Embeddable
public class StoragePK implements Serializable {

    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "player")
    private String player;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 45)
    @Column(name = "resource")
    private String resource;

    public StoragePK() {
    }

    public StoragePK(String player, String resource) {
        this.player = player;
        this.resource = resource;
    }

    public String getPlayer() {
        return player;
    }

    public void setPlayer(String player) {
        this.player = player;
    }

    public String getResource() {
        return resource;
    }

    public void setResource(String resource) {
        this.resource = resource;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (player != null ? player.hashCode() : 0);
        hash += (resource != null ? resource.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof StoragePK)) {
            return false;
        }
        StoragePK other = (StoragePK) object;
        if ((this.player == null && other.player != null) || (this.player != null && !this.player.equals(other.player))) {
            return false;
        }
        if ((this.resource == null && other.resource != null) || (this.resource != null && !this.resource.equals(other.resource))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "entity.StoragePK[ player=" + player + ", resource=" + resource + " ]";
    }
}
